<template>
    <div
        class="shop-con"
        :style="{
            borderRadius: `${data.rpxStyle['border-radius']}px`,
        }"
    >
        <div
            class="shop-head cls-between"
            :style="{
                background: `linear-gradient(180deg, ${data.style.start_color}, #fff)`,
            }"
        >
            <div class="shop-head__left cls-flex line-one">
                <img :src="data.data.custom_icon ? data.data.custom_icon : proxy.imgUrl + 'tenant_593be52a46f869eea8b31d146d21de7a/album/202304/20230427_81d5c11a5181d80383c10b91f1030289.png'" />
                <span class="shop-head__name" :style="{ color: data.style.head_color }">{{ data.data.shop_name }}</span>
            </div>
            <div class="shop-head__right cls-flex" :style="{ color: data.style.head_color }">
                更多<el-icon :color="data.style.head_color" size="14px"><ArrowRight /></el-icon>
            </div>
        </div>
        <div class="shop-info-con" v-for="(shop, si) in data.data.data" :key="si">
            <div class="cls-flex">
                <img :src="proxy.imgUrl + shop.logo" class="shop-logo" v-if="shop.logo" />
                <div class="shop-right">
                    <div class="shop-info__title">
                        <div class="shop-right__title line-one">{{ shop.title }}</div>
                        <div class="shop-info__rate cls-flex">{{ shop.avg_score * 1 || "5.0" }}分</div>
                    </div>
                    <div class="shop-foot flexs">
                        <div class="shop-foot__arrs line-one" v-if="shop.tag_list && shop.tag_list.length > 0">
                            <template v-for="(item, index) in shop.tag_list" :key="item.tag_id">
                                <el-tag :color="item.color" size="small" effect="dark" v-if="index < 4">
                                    {{ item.title }}
                                </el-tag>
                            </template>
                        </div>
                        <div class="shop-foot__arrs line-one" v-else>
                            <el-tag color="#c8c9cc" size="small" effect="dark"> 无标签 </el-tag>
                        </div>
                    </div>
                    <el-button class="shop-info__to" color="#FD7047" plain round size="small">进店</el-button>
                </div>
            </div>
            <div class="good-list cls-flex">
                <div class="good-item" v-for="(pdc, pi) in shop.product_list" :key="pi">
                    <img :src="proxy.imgUrl + pdc.product_img + '!img_200'" class="shop-pdc-img" v-if="pdc.product_img" />
                    <div class="good-name line-one">{{ pdc.product_name }}</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { getCurrentInstance, ref } from "vue"
import { ArrowRight } from "@element-plus/icons-vue"

const { proxy } = getCurrentInstance()

/**
 * 门店列表-供应商
 * @property {Object} data  数据
 */
const props = defineProps({
    data: {
        type: Object,
        default: {
            id: 7,
            type_name: "shopList",
            text: "门店列表",
            style: {
                background: "#fff",
                color: "#333",
                icon_switch: false,
            },
            data: {
                data: [],
            },
        },
    },
})
</script>

<style lang="less" scoped>
.good-list {
    margin-top: 14px;
    .good-item {
        width: 80px;
        overflow: hidden;
        margin-right: 8px;
        &:nth-child(4n) {
            margin-right: 0;
        }
        .shop-pdc-img {
            width: 80px;
            height: 80px;
            border-radius: 10px;
        }
        .good-name {
            font-size: 14px;
            color: #333;
            line-height: 30px;
            flex: none;
            text-align: center;
        }
    }
}

.shop-con {
    // background: linear-gradient(180deg, #ffeeea 0%, #ffffff 19%);
    padding-bottom: 6px;
    background-color: #fff;
    overflow: hidden;
    .shop-head {
        padding: 0px 14px;
        margin-bottom: 10px;
        overflow: hidden;
        height: 42px;
        .shop-head__left {
            flex: 1;
            margin-right: 20px;
            img {
                width: 14px;
                height: 14px;
                overflow: hidden;
            }
            .shop-head__name {
                font-weight: bold;
                font-size: 16px;
                margin-left: 6px;
            }
        }
        .shop-head__right {
            flex: none;
            font-size: 13px;
        }
        .shop-title {
            margin-left: 10px;
            width: 84px;
        }
    }
    .shop-logo {
        width: 40px;
        height: 40px;
        flex: none;
        border-radius: 5px;
    }

    .shop-info-con {
        padding: 10px 14px;
        border-bottom: 1px solid #f7f7f9;
        &:last-child {
            border-bottom: 0;
        }
    }
    .shop-right {
        padding-left: 10px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        min-height: 40px;
        overflow: hidden;
        position: relative;
        .shop-right__title {
            max-width: 170px;
        }
        .shop-info__title {
            font-size: 14px;
            font-weight: 600;
            margin-bottom: 2px;
            overflow: hidden;
            display: flex;
            align-items: center;
            flex: 1;
        }
        .shop-info__rate {
            font-size: 14px;
            color: #fd764f;
            flex: none;
            margin-left: 8px;
            :deep(.el-rate) {
                height: auto;
                .el-rate__icon {
                    margin-right: 0px;
                }
                .el-rate__text {
                    color: #fd764f;
                    margin-left: 2px;
                    font-size: 14px;
                }
            }
        }
    }
    .shop-foot {
        overflow: hidden;
        .shop-foot__arrs {
            flex: 1;
            .el-tag {
                margin-right: 6px;
                padding: 0px 4px;
                border-width: 0;
                &:last-child {
                    margin-right: 0;
                }
            }
        }
        .el-button {
            flex: none;
        }
    }
}

.shop-info__to {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}
</style>
